import axios from "axios"
import qs from "qs"
// import store from "@/store"
const instance = axios.create()
// //为axios发送的每一个请求，添加请求拦截器，处理token字符串
// instance.interceptors.request.use(function (config) {
//   //config对象保存着请求对象的配置信息，此处可以进行修改
//   config.headers["Authorization"] = store.state.token
//   //返回处理后的config对象
//   return config
// })


// 允许跨域
// axios.defaults.withCredentials = true;
let myaxios = {
  get(url, params) {
    return instance({
      url,
      method: "GET",
      params,
    })
  },
  post(url, params) {
    return instance({
      url,
      method: "POST",
      data: qs.stringify(params),
    })
  },
  delete(url, params) {
    return instance({
      url,
      method: "DELETE",
      data: qs.stringify(params),
    })
  },
  put(url, params) {
    return instance({
      url,
      method: "PUT",
      data: qs.stringify(params),
    })
  },
}

export default myaxios
